
package com.eworking.eim.message.body;

import java.io.File;

import com.eworking.eim.util.EIMLog;

import android.os.Parcel;
import android.os.Parcelable;

public class VoiceMessageBody extends FileMessageBody {
    
    /** 语音长度 */
    public int length = 0;
    
    public static final Parcelable.Creator<VoiceMessageBody> CREATOR = new Parcelable.Creator<VoiceMessageBody>() {
        
        @Override
        public VoiceMessageBody createFromParcel(Parcel source) {
            return new VoiceMessageBody(source);
        }
        
        @Override
        public VoiceMessageBody[] newArray(int size) {
            return new VoiceMessageBody[size];
        }
    };
    
    public VoiceMessageBody(File file, int paramInt) {
        if (!(file.exists()))
            throw new IllegalArgumentException("voice file doesn't exists:" + file.getAbsolutePath());
        this.localUrl = file.getAbsolutePath();
        this.fileName = file.getName();
        this.length = paramInt;
        EIMLog.d("voicemsg", "create voice, message body for:" + file.getAbsolutePath());
    }
    
    public VoiceMessageBody(String paramString1, String paramString2, int paramInt) {
        this.fileName = paramString1;
        this.remoteUrl = paramString2;
        this.length = paramInt;
    }
    
    public int getLength() {
        return this.length;
    }
    
    public String toString() {
        return "voice:" + this.fileName + ",localurl:" + this.localUrl + ",remoteurl:" + this.remoteUrl + ",length:"
            + this.length;
    }
    
    public int describeContents() {
        return 0;
    }
    
    public void writeToParcel(Parcel parcel, int paramInt) {
        parcel.writeString(this.fileName);
        parcel.writeString(this.localUrl);
        parcel.writeString(this.remoteUrl);
        parcel.writeInt(this.length);
    }
    
    private VoiceMessageBody(Parcel parcel) {
        this.fileName = parcel.readString();
        this.localUrl = parcel.readString();
        this.remoteUrl = parcel.readString();
        this.length = parcel.readInt();
    }
}
